#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(){
  int ret = fork();
  if(ret < 0){
    perror("fork");
    return 1;
  }
  else if(ret == 0){
    printf("i am child, pid = [%d], ppid = [%d]\n", getpid(), getppid());
    sleep(1); 
    printf("i am child, pid = [%d], ppid = [%d]\n", getpid(), getppid());
  }
  else{
    printf("i am father, pid = [%d], ppid = [%d]\n", getpid(), getppid());
    exit(0);
  }
  return 0;
}
